import { memo } from 'react';
import { ContextProvider } from './context';
import SearchForm from './c-cpns/SearchForm';
import TableContent from './c-cpns/TableContent';
import type { PropsWithChildren, ReactElement } from 'react';
import type { AnyObject, MainTableProps } from './type';

const TablePro = memo(
	<R extends AnyObject, P extends AnyObject>(props: PropsWithChildren<MainTableProps<R, P>>) => {
		return (
			<ContextProvider>
				<SearchForm
					search={props.search}
					formConfig={props.formConfig}
					formRef={props.formRef}
					onSearchFormChange={props.onSearchFormChange}
				/>
				<TableContent {...props} />
			</ContextProvider>
		);
	}
) as <Record = AnyObject, Param = AnyObject>(
	props: PropsWithChildren<MainTableProps<Record, Param>>
) => ReactElement;

export default TablePro;
